﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Map.aspx.cs" MasterPageFile="~/Site.Master"
    Inherits="Fujitsu.JiraAnalysis.UI.Map" %>

<%@ Import Namespace="Fujitsu.JiraAnalysis.DAL" %>
<asp:Content ContentPlaceHolderID="MainContent" runat="server">
    <link rel="StyleSheet" href="Styles/Site.css" type="text/css" />
    <asp:ObjectDataSource runat="server" ID="ProjectsDataSource" SelectMethod="GetAllProjects"
        TypeName="Fujitsu.JiraAnalysis.DAL.ProjectStorage" >
        <SelectParameters>
            <asp:SessionParameter SessionField="JiraUrl" Name="jiraUrl"/>
        </SelectParameters>
        </asp:ObjectDataSource>
    <h3 class="green_header" runat="server" id="savedHeader" visible="false">
        Mapping is saved</h3>
    <h2><a href="AddProject.aspx"> Add new project</a> or Select existing project: 
    <asp:DropDownList runat="server" ID="dropDownProjects" DataSourceID="ProjectsDataSource"
        DataTextField="ProjectKey" DataValueField="ID" OnSelectedIndexChanged="dropDownProjects_SelectedIndexChanged"
        AutoPostBack="true" ondatabound="dropDownProjects_DataBound">
        <asp:ListItem Selected="True" Text="-select project-" Value="-1" />
    </asp:DropDownList> </h2>    
    <div runat="server" id="container">
    <asp:ObjectDataSource runat="server" ID="IssueTypeDataSource" SelectMethod="GetIssueTypes"
        TypeName="Fujitsu.JiraAnalysis.DAL.IssuesTypeStorage" />
    <fieldset id="fieldsetIssueTypeMapping" runat="server" visible="false">
        <legend>Issue Type Mapping</legend>
        <asp:Repeater ID="repeaterIssueTypes" runat="server" onitemdatabound="repeater_ItemDataBound">
            <HeaderTemplate>
                <table cellspacing="5" width="40%">
                    <th>
                        Jira
                    </th>
                    <th>
                        Internal
                    </th>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td width="50%">
                        <asp:Literal runat="server" ID="jiraName" Text='<%# Eval("name")%>' />
                    </td>
                    <td>
                        <asp:HiddenField runat="server" ID="jiraID" Value='<%# Eval("id")%>' />
                        <asp:DropDownList runat="server" ID="dropDownList" Name='<%# Eval("id") %>' DataSourceID="IssueTypeDataSource"
                            DataValueField="ID" DataTextField="Name" />
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </fieldset>
    <asp:ObjectDataSource runat="server" ID="IssuePriorityDataSource" SelectMethod="GetPriorities"
        TypeName="Fujitsu.JiraAnalysis.DAL.PriorityStorage" />
    <fieldset id="fieldsetIssuePriorityMapping" runat="server" visible="false">
        <legend>Issue Priority Mapping</legend>
        <asp:Repeater ID="repeaterIssuePriority" runat="server" OnItemDataBound="repeater_ItemDataBound">
            <HeaderTemplate>
                <table cellspacing="5" width="40%">
                    <th>
                        Jira
                    </th>
                    <th>
                        Internal
                    </th>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td width="50%">
                        <asp:Literal runat="server" ID="jiraName" Text='<%# Eval("name")%>' />
                    </td>
                    <td>
                        <asp:HiddenField runat="server" ID="jiraID" Value='<%# Eval("id")%>' />
                        <asp:DropDownList runat="server" ID="dropDownList" Name='<%# Eval("id") %>'
                            DataSourceID="IssuePriorityDataSource" DataValueField="ID" DataTextField="Name" />
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </fieldset>
    <asp:ObjectDataSource runat="server" ID="IssueStatusDataSource" SelectMethod="GetStatuses"
        TypeName="Fujitsu.JiraAnalysis.DAL.StatusStorage" />
    <fieldset id="fieldsetIssueStatusMapping" runat="server" visible="false">
        <legend>Issue Status Mapping</legend>
        <asp:Repeater ID="repeaterIssueStatus" runat="server" OnItemDataBound="repeater_ItemDataBound">
            <HeaderTemplate>
                <table cellspacing="5" width="40%">
                    <th>
                        Jira
                    </th>
                    <th>
                        Internal
                    </th>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td width="50%">
                        <asp:Literal runat="server" ID="jiraName" Text='<%# Eval("name")%>' />
                    </td>
                    <td>
                        <asp:HiddenField runat="server" ID="jiraID" Value='<%# Eval("id")%>' />
                        <asp:DropDownList runat="server" ID="dropDownList" Name='<%# Eval("id") %>'
                            DataSourceID="IssueStatusDataSource" DataValueField="ID" DataTextField="Name" />
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </fieldset>
    <asp:ObjectDataSource runat="server" ID="IssueResolutionDataSource" SelectMethod="GetResolutions"
        TypeName="Fujitsu.JiraAnalysis.DAL.ResolutionStorage" />
    <fieldset id="fieldsetIssueResolutionMapping" runat="server" visible="false">
        <legend>Issue Resolution Mapping</legend>
        <asp:Repeater ID="repeaterIssueResolution" runat="server" OnItemDataBound="repeater_ItemDataBound">
            <HeaderTemplate>
                <table cellspacing="5" width="40%">
                    <th>
                        Jira
                    </th>
                    <th>
                        Internal
                    </th>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td width="50%">
                        <asp:Literal runat="server" ID="jiraName" Text='<%# Eval("name")%>' />
                    </td>
                    <td>
                        <asp:HiddenField runat="server" ID="jiraID" Value='<%# Eval("id")%>' />
                        <asp:DropDownList runat="server" ID="dropDownList" Name='<%# Eval("id") %>'
                            DataSourceID="IssueResolutionDataSource" DataValueField="ID" DataTextField="Name" />
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </fieldset>
    <br/><br/>
    <asp:Button class="inputButton" runat="server" ID="btnSave" Text="Save" OnClick="btnSave_Click" Visible="false" />
    </div>
</asp:Content>
